{extend name="base" /}
{block name="body"}
<div class="layui-card">
    <div class="layui-card-header">
        <div class="layui-btn-group">
            <a href="{:url('store/notice/add')}" class="layui-btn ajax-iframe" data-width="650px" data-height="100%">添加</a>
        </div>
    </div>
    <div class="layui-tab layui-tab-card">
        <ul class="layui-tab-title">
            {foreach name="list" item="d"}
            <li class="{if $date == $d.day}layui-this bg-success {/if}" style="padding:0 10px 0 10px;" ><a href="{:url('store/notice/detail',['date'=>$d['day']])}">{$d.day}</a></li>
            {/foreach}
        </ul>
        <div class="layui-tab-content">

            <table id="tableList" lay-filter="tableList"></table>
        </div>
    </div>

    <!-- 表格操作列 -->
    <script type="text/html" id="tableTBTrack">
        {{# if(d.status == '0'){ }}
        <a href="{:url('store/notice/edit')}?id={{d.id}}&status=1" class="layui-btn layui-btn-sm ajax-action">未读</a>
        {{# }else{ }}
        <a href="{:url('store/notice/edit')}?id={{d.id}}&status=0" class="layui-btn layui-btn-primary layui-btn-sm ajax-action">已读</a>
        {{# } }}
        <a href="{:url('store/notice/del')}?id={{d.id}}" class="layui-btn layui-btn-danger layui-btn-sm ajax-delete">删除</a>
    </script>
    <!-- 权限列 -->
    <script type="text/html" id="type">
        {{# if(d.type == 'track'){ }}
        <a class="layui-btn layui-btn-sm layui-btn-normal">跟进/回访提醒</a>
        {{# }else if(d.type == 'contract'){ }}
        <a class="layui-btn layui-btn-normal layui-btn-sm">合同事项提醒</a>
        {{# }else if(d.type == 'birthday'){ }}
        <a class="layui-btn layui-btn-normal layui-btn-sm">生日提醒</a>
        {{# }else if(d.type == 'other'){ }}
        <a class="layui-btn layui-btn-normal layui-btn-sm">其他提醒</a>
        {{# } }}
    </script>
    <!-- 权限列 -->
    <script type="text/html" id="customer">
        {{# if(d.customer_id != '0'){ }}
        <a href="{:url('store/customer/detail')}?id={{d.customer_id}}" class="layui-btn layui-btn-primary layui-btn-sm">{{d.customer.name}}</a>
        {{#  } }}
    </script>
</div>
{/block}

{block name="js"}
<script>
    layui.use(['layer', 'form', 'table', 'util', 'dropdown'], function () {

        var table = layui.table;
        // 渲染回访表格
        var insTb = table.render({
            elem: '#tableList',
            url: "{:url('store/notice/detail_json')}",
            where:{
                date:"{$date}",
            },
            page: true,
            cellMinWidth: 100,
            limit:'15',
            limits:[15,30,50,100,200,500,1000],
            size:'lg',even:true,
            cols: [[
                {type:'numbers',title:'#'},
                {templet: '#type', align: 'left', sort: true, title: '类型',width:200},
                {templet: '#customer', align: 'left', sort: true, title: '客户',width: 220},
                {field: 'remark', align: 'left', sort: true, title: '提醒事项'},
                {field: 'create_time', align: 'center', sort: true, title: '创建时间',width: 200},
                {align: 'center', toolbar: '#tableTBTrack', title: '操作', width: 160}
            ]],
            parseData: function(res){ //res 即为原始返回的数据
                return {
                  "code": res.code, //解析接口状态
                  "msg": res.msg, //解析提示文本
                  "count": res.data.total, //解析数据长度
                  "data": res.data.data //解析数据列表
                };
            }
        });

    });

</script>
{/block}